const addClass = (el, className) => {
  const elClass = el.className
  if (elClass) {
    let source = elClass.split(' ')
    if (source.indexOf(className) === -1) {
      source.push(className)
      el.className = source.join(' ')
    }
    
  } else {
    // 没有添加过className
    el.className = className
  }

}

const removeClass = (el, className) => {
  const elClass = el.className
  if (elClass) {
    let source = elClass.split(' ')
    if (source.indexOf(className) > -1) {
      source.splice(source.indexOf(className), 1)
      el.className = source.join(' ')
    }
  }
}

module.exports = {
  addClass,
  removeClass
}